package com.hshoesmall.demo.controller;

import com.hshoesmall.demo.common.api.ApiResult;
import com.hshoesmall.demo.model.entity.Color;
import com.hshoesmall.demo.service.ColorService;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController

@RequestMapping("/color")
public class ColorController {

    @Resource
    private ColorService colorService;

    @RequestMapping(value="/getAllColor", method = RequestMethod.POST)
    public ApiResult<Map<String, Object>> getColorList(){

        List<Color> color = colorService.findColorList();
        if(ObjectUtils.isEmpty(color)) {
            return ApiResult.failed("操作失败");
        }
        Map<String, Object> map = new HashMap<>(16);
        map.put("color", color);
        return ApiResult.success(map);
    }

}
